package com.Test;


import java.util.HashMap;
import java.util.concurrent.locks.ReentrantLock;

/**
 * Description:
 * Copyright:   Copyright (c)2019
 * Company:     zefu
 *
 * @author: 张李鑫
 * @version: 1.0
 * Create at:   2021-09-30 15:58:29
 * <p>
 * Modification History:
 * Date         Author      Version     Description
 * ------------------------------------------------------------------
 * 2021-09-30     张李鑫                     1.0         1.0 Version
 */
public class B {

    public static int solve(String nums) {
        // write code here
        return process(nums.toCharArray(), 0);
    }

    public static int process(char[] str, int l) {

        if (l == str.length) {
            return 1;
        }
        if (str[l] == '0') {
            return 0;
        }

        int p = process(str, l + 1);
        if (l + 1 < str.length && (str[l] - '0') * 10 + (str[l + 1] - '0') < 27) {
            p += process(str, l + 2);
        }
        return p;
    }

    public static void main(String[] args) {
        new Object();
        System.out.println(solve("0"));
        System.out.println(dp("31717126241541717"));
    }


    public static int dp(String nums) {
        if (nums == null || nums.length() == 0) {
            return 0;
        }
        int[] dp = new int[nums.length() + 1];
        dp[nums.length()] = 1;
        for (int i = nums.length() - 1; i >= 0; i--) {
            if (nums.charAt(i) == '0') {
                dp[i] = 0;
            } else {
                dp[i] = dp[i + 1];
                if (i + 1 < nums.length() && (nums.charAt(i) - '0') * 10 + (nums.charAt(i + 1) - '0') < 27) {
                    dp[i] += dp[i + 2];
                }
            }
        }
        return dp[0];
    }

}
